#! /bin/sh

# Write EEPROM to Amp4 and play a test tone

OUT=/dev/tty1

case "$1" in
    start)
	# Program EEPROM
        PATH=$PATH:/opt/hifiberry/contrib
        export PATH

        AP=`aplay -l | grep Pro`
        if [ "$AP" == "" ]; then
		echo "Didn't detect Pro version, aborting"
		exit 1
	fi

        /opt/hifiberry/contrib/hbflash.sh -w -f=/opt/hifiberry/contrib/amp4.eep -t=24c32
	if [ "$?" != "0" ]; then
		echo "Couldn't program EEPROM"
		exit 1
	fi

	amixer sset Digital 72%
        play -n synth 60 sine 1000  &

	;;
    stop)
	;;
    restart)
	$0 stop
	$0 start
	;;
    *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
	;;
esac

